﻿#include <QObject>
#include <QDebug>
#include <QTime>

class MyObject : public QObject {
    Q_OBJECT
    Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY messageChanged)
public:
    explicit MyObject(QObject *parent = nullptr) : QObject(parent), m_message("Hello from C++!") {}

    QString message() const { return m_message; }
    void setMessage(const QString &msg) {
        if (m_message != msg) {
            m_message = msg;
            emit messageChanged();
        }
    }

    Q_INVOKABLE void updateMessage() {
        setMessage("Message Updated at: " + QTime::currentTime().toString());
        qDebug() << "[C++] Message updated to:" << m_message;
    }

signals:
    void messageChanged();

private:
    QString m_message;
};